/**
 * @param {number} target
 * @param {number[]} nums
 * @return {number}
 */
var minSubArrayLen = function (target, nums) {
  let res = Number.MAX_SAFE_INTEGER,left=0,right=0,sum=0
  while(left<nums.length){
    if(sum<target){
      sum+=nums[right]
      right++
    }else if(sum>target){
      sum-=nums[left]
      left++
    }else{
      res = Math.min(res,right-left+1)
      sum-=nums[left]
      left++
    }
  }
  return res
};

minSubArrayLen(7,[2,3,1,2,4,3])